var app=new Vue({
    el:"#app",
    data:{
        ticket:{
            companyName:"",
            money:"",
            subject:"",
            body:"",
            type:"",
        }
        },
    methods:{
        //提交
        submited:function(){
            if(this.ticket.companyName==null||this.ticket.companyName==''||
                this.ticket.money==null||this.ticket.money==''||
                this.ticket.subject==null||this.ticket.subject==''||
                this.ticket.body==null||this.ticket.body==''||
                this.ticket.type==null||this.ticket.type=='')
            {
                alert("请填写完整信息");
            }
            else{
            axios.post("/ticket/submitticket",{
                companyName:this.ticket.companyName,
                money:this.ticket.money,
                subject:this.ticket.subject,
                body:this.ticket.body,
                type: this.ticket.type
            })
                .then(function (response) {
                    alert("提交成功");
                    window.location.reload();
                }),function (err) {
                alert("提交失败");
                console.log(err);
            }
            }
        },
//保存
        saved:function(){
            if(this.ticket.companyName==null||this.ticket.companyName==''||
                this.ticket.money==null||this.ticket.money==''||
                this.ticket.subject==null||this.ticket.subject==''||
                this.ticket.body==null||this.ticket.body==''||
                this.ticket.type==null||this.ticket.type=='')
            {
                alert("请填写完整信息");
            }
            else{
            axios.post("/ticket/saveticket",{
                companyName:this.ticket.companyName,
                money:this.ticket.money,
                subject:this.ticket.subject,
                body:this.ticket.body,
                type: this.ticket.type
            })
                .then(function (response) {
                    alert("保存成功");
                    window.location.reload();
                }),function (err) {
                alert("保存失败");
                console.log(err);
            }
            }
        }
    }
    }
)